﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetSysData;

namespace BladeTecWebApplication.Admin
{
	public partial class AddPosition : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				NetSysData.NetSysData data = new NetSysData.NetSysData();
				QUIZ[] quizzes = data.GetQuizzes();

				ddlQuiz.Items.Add(new ListItem("Select ...", ""));
				foreach (QUIZ quiz in quizzes)
				{
					ddlQuiz.Items.Add(new ListItem(quiz.QUIZ_NAME, quiz.QUIZ_ID.ToString()));
				}
			}
		}

		protected void btnAddPosition_Click(object sender, EventArgs e)
		{
			NetSysData.NetSysData data = new NetSysData.NetSysData();
			POSITION newPosition = new POSITION();
			newPosition.POSITION_TITLE = txtPositionTitle.Text;
			newPosition.HIRE_DATE = DateTime.Parse(hireDate.Value);
			newPosition.QUIZ_ID = Int32.Parse(ddlQuiz.SelectedValue);

			data.AddPosition(newPosition);

			lblTitle.Text = newPosition.POSITION_TITLE;
			lblHireDate.Text = hireDate.Value;

			pnlPositionForm.Visible = false;
			pnlConfirmationForm.Visible = true;

		}
	}
}